const tags = /^(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
function convert(html) {
    return html.replace(
        /(<(\w+)[^>]*?)\/>/g, (all, front, tag) => {
            return tags.test(tag) ? all : front + "></" + tag + ">"
        }
    )
}

function getNodes(htmlString, doc) {
    const map = {
        "<td": [3, "<table><tbody><tr>","</tr></tbody></table>"],
        "<th": [3, "<table><tbody><tr>","</tr></tbody></table>"],
        "<tr": [2, "<table><thead>","</thead></table>"],
        "<option": [1, "<select multiple>","</select>"],
        "<optgroup": [1, "<select multiple>","</select>"],
        "<legend": [1, "<fieldset>","</fieldset>"],
        "<thead": [1, "<table>","</table>"],
        "<tbody": [1, "<table>","</table>"],
        "<tfoot": [1, "<table></table>"],
        "<colgroup": [1, "<table>","</table>"],
        "<caption": [1, "<table>","</table>"],
        "<col": [2, "<table><tbody></tbody><colgroup>","</colgroup></table>"],
    };
    const tagName = htmlString.match(/<\w+>/);
    let mapEntry = tagName ? map[tagName[0]] : null;
    if(!mapEntry) {mapEntry = [0, " ", " "];}
    let div = (doc || document).createElement("div");
    div.innerHTML = mapEntry[1] + htmlString + mapEntry[2];
    while (mapEntry[0]--){div=div.lastChild;}
    return div.childNodes
}